package com.sidianzhong.sdz.controller;


import com.sidianzhong.sdz.model.WebAequipmentgroup;
import com.sidianzhong.sdz.model.WebStationmaterials;
import com.sidianzhong.sdz.service.WebAequipmentgroupService;
import com.sidianzhong.sdz.service.WebStationmaterialsService;
import com.sidianzhong.sdz.utils.PageInfo;
import com.sidianzhong.sdz.utils.ResultModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by hxg on 2016/10/06.
 */

@Api(description = "信息查询")
@RestController
public class WebStationmaterialsController {
    @Autowired
    private WebStationmaterialsService webStationmaterialsService;

    @ApiOperation(value = "查询微波设备")
    @RequestMapping(value = "/webStationmaterials",
            method = {RequestMethod.GET},
            produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object getWebStationmaterials(
            HttpServletRequest request,
            @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
            @RequestParam(value = "sortItem", required = false, defaultValue = "id") String sortItem,
            @RequestParam(value = "sortOrder", required = false, defaultValue = "desc") String sortOrder,
            @RequestParam(value = "materialname", required = false) String materialname,
            @RequestParam(value = "materialtype", required = false) Integer materialtype,
            @RequestParam(value = "equipmenttypekey", required = false) String equipmenttypekey,
            @RequestParam(value = "equipmentkey", required = false) String equipmentkey,
            @RequestParam(value = "subtype", required = false) Integer subtype
    ) {
        WebStationmaterials item = new WebStationmaterials();
        if (materialname == null || materialname.equals("")) {
            //查询所有
        } else {
            item.setMaterialname(materialname);
        }
        if (materialtype == null || materialtype==0) {
            //查询所有
        } else {
            item.setMaterialtype(materialtype);
        }
        if (equipmenttypekey == null || equipmenttypekey.equals("")) {
            //查询所有
        } else {
            item.setEquipmenttypekey(equipmenttypekey);
        }
        if (equipmentkey == null || equipmentkey.equals("")) {
            //查询所有
        } else {
            item.setEquipmentkey(equipmentkey);
        }
        if (subtype == null || subtype==0) {
            //查询所有
        } else {
            item.setSubtype(subtype);
        }


        PageInfo<WebStationmaterials> list = webStationmaterialsService.getListWithPaging(pageNum, pageSize, sortItem, sortOrder, item);
        return new ResponseEntity<>(ResultModel.ok(list), HttpStatus.OK);

    }


}
